package com.crazymaker.demo.proxy.basic;

import com.crazymaker.springcloud.seckill.remote.client.DemoClient;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

@Slf4j
public class DemoClientInocationHandler implements InvocationHandler
{

    //代理实例
    private DemoClient delegate;

    public DemoClientInocationHandler(DemoClient delegate)
    {
        this.delegate = delegate;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    {

        log.info("{} 方法被调用", method.getName());
        Object result = method.invoke(delegate, args);

        return result;
    }


}